package com.hht.study.proxy.dynamic.cglib;

import net.sf.cglib.proxy.MethodInterceptor;
import net.sf.cglib.proxy.MethodProxy;

import java.lang.reflect.Method;

/**
 * @author hht
 * @date 2022/3/6
 */
public class MyMethodInterceptor implements MethodInterceptor {

    /**
     * q3
     * @param o 代理对象
     * @param method 代理的方法
     * @param objects 参数
     * @param methodProxy 用于执行原方法
     * @return
     * @throws Throwable
     */
    @Override
    public Object intercept(Object o, Method method, Object[] objects, MethodProxy methodProxy) throws Throwable {
        System.out.println("cglib动态代理,增强方法："+method.getName());
        Object invoke = methodProxy.invokeSuper(o, objects);
        return invoke;
    }
}
